package com.elitesland.b2c.com.entity;

import com.elitesland.core.base.BaseModel;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author shihao.ma
 * @since 2020/6/16
 */
@Data
@Entity
@Table(name = "com_file")
@org.hibernate.annotations.Table(appliesTo = "com_file", comment = "文件上传日志表")
public class ComFileDO extends BaseModel implements Serializable {

    private static final long serialVersionUID = -1511065033699247029L;

    @Column(name = "original_name", columnDefinition = "varchar(516) comment '文件原名称'")
    private String originalName;

    @Column(name = "upload_name", columnDefinition = "varchar(256) comment '文件上传名称'")
    private String uploadName;

    @Column(name = "file_path", columnDefinition = "varchar(1000) comment '文件地址'")
    private String filePath;

    @Column(name = "file_size", columnDefinition = "int(10) comment '文件大小'")
    private Long fileSize;

    @Column(name = "suffix", columnDefinition = "varchar(32) comment '后缀名'")
    private String suffix;

    @Column(name = "mime_type", columnDefinition = "varchar(256) comment '文件类型'")
    private String mimeType;

    @Column(name = "file_code", columnDefinition = "varchar(256) comment '文件编码'", nullable = false)
    private String fileCode;

    @Column(name = "file_url", columnDefinition = "varchar(1000) comment '访问路径'")
    private String fileUrl;

    @Column(name = "thumbnail_file_code", columnDefinition = "varchar(256) comment '缩略图文件编码'")
    private String thumbnailFileCode;

    @Column(name = "thumbnail_file_path", columnDefinition = "varchar(1000) comment '缩略图文件地址'")
    private String thumbnailFilePath;

    @Column(name = "thumbnail_file_url", columnDefinition = "varchar(1000) comment '缩略图文件下载路径'")
    private String thumbnailFileUrl;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof ComFileDO)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        ComFileDO entity = (ComFileDO) o;
        return getId().equals(entity.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId());
    }

}
